import java.util.Scanner;

public class Main1 {

    public static String fun(int k) {
        int a = 0, b = 1, c = 1;
        for (int i = 1; i < k; i++) {
            if (b > 9999 && c > 9999) {
                String s1 = Integer.toString(b);
                b = Integer.parseInt(s1.substring(s1.length() - 4));
                String s2 = Integer.toString(c);
                c = Integer.parseInt(s2.substring(s2.length() - 4));
                String s3 = Integer.toString(a);
                a = Integer.parseInt(s3.substring(s3.length() - 4));
            }
            a = b + c;
            b = c;
            c = a;
        }
        if (a == 0) {
            a = 1;
        }
        String s = Integer.toString(a);
        if (a > 9999) {
            return s.substring(s.length() - 4);
        } else if (a < 1000) {
            StringBuilder str = new StringBuilder();
            for (int i = 0; i < 4 - s.length(); i++) {
                str.append("0");
            }
            str.append(s);
            return str.toString();
        } else {
            return s;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int[] arr = new int[n];
            StringBuilder str = new StringBuilder();
            for (int i = 0; i < n; i++) {
                arr[i] = scanner.nextInt();
                str.append(fun(arr[i]));
            }
            System.out.println(str);
        }

    }
}
